# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.shortcuts import render
# Create your views here.
from django.http import HttpResponse
from django.shortcuts import HttpResponse
from recognition.models import IMG
from recognition.MeterReader import METER


def index(request):
    """
    index视图
    :param request: 包含了请求信息的请求对象
    :return: 响应对象
    """
    return HttpResponse("hello the world!")



def uploadImg(request):
      print ("调用图片上传接口")
      if request.method == 'POST':
          name = request.POST.get('name','')
          print (name)
          new_img = IMG(img = request.FILES.get('img'))    
          new_img.save()
          recognition()
      return HttpResponse("upload OK")
      

def recognition():
    #得到刻度
    picpath = "/home/andy/projectSrc/PythonSrc/robotvision/version/upload/test.jpg"
    METER(picpath).iden_pic()

 
    #返回刻度值

    return "abc"
